﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Istrib.Sound;
using Istrib.Sound.Formats;

namespace MyWords
{
    public partial class FrmRecordDevice : Form
    {
        public FrmRecordDevice()
        {
            InitializeComponent();
        }

        public SoundCaptureDevice CaptureDevice;
        public PcmSoundFormat SoundFormat;

        private void FrmRecordDevice_Load(object sender, EventArgs e)
        {
            foreach (SoundCaptureDevice device in SoundCaptureDevice.AllAvailable)
            {
                devicesCmb.Items.Add(device);
            }
            devicesCmb.SelectedIndex = 0;

            //LoadAvailableFormats(PcmSoundFormat.StandardFormats);
            formatsCmb.Visible = false;
            label1.Visible = false;
            SoundFormat = new PcmSoundFormat(12000, 16, 1);
        }

        private void devicesCmb_SelectedIndexChanged(object sender, EventArgs e)
        {
            CaptureDevice = (SoundCaptureDevice)devicesCmb.SelectedItem;
        }

        private void formatsCmb_SelectedIndexChanged(object sender, EventArgs e)
        {
            SoundFormat = (PcmSoundFormat)formatsCmb.SelectedItem;
        }



        private void LoadAvailableFormats(IEnumerable<PcmSoundFormat> formats)
        {
            formatsCmb.Items.Clear();

            foreach (PcmSoundFormat format in formats)
            {
                formatsCmb.Items.Add(format);
            }

            formatsCmb.SelectedIndex = 0;
        }

    }
}
